package com.ophiux.system.controller;

import com.ophiux.common.core.utils.R;
import com.ophiux.common.security.annotation.Inner;
import com.ophiux.system.service.SysSocialDetailsService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * @desc: 社交登录账号表
 * @author: hhl
 * @date：2023/12/9 20:54
 */
@RestController
@RequestMapping("/social")
@AllArgsConstructor
@Api(tags = "三方账号管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysSocialDetailsController {

    private final SysSocialDetailsService sysSocialDetailsService;

    /**
     * 通过社交账号、手机号查询用户、角色信息
     *
     * @param inStr appid@code
     * @return
     */
    @Inner
    @GetMapping("/info/{inStr}")
    public R getUserInfo(@PathVariable String inStr) {
        return R.ok(sysSocialDetailsService.getUserInfo(inStr));
    }

    /**
     * 绑定社交账号
     *
     * @param state 类型
     * @param code  code
     * @return
     */
    @PostMapping("/bind")
    public R bindSocial(String state, String code) {
        return R.ok(sysSocialDetailsService.bindSocial(state, code));
    }

}
